﻿@model ConferenceTransferEvidenceModel
@{
	ViewBag.Title = Resources.ConferenceTransferEvidence + ConstValues.strDash + ViewBag.ConferenceName;
}
<div id="searchBar">
	<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
		@Resources.FullName：<input id="queryFullName" class="easyui-textbox" style="height:27px; width:200px;" />&nbsp;&nbsp;
		@Resources.PaidStatus：<select id="queryHasPaid" class="easyui-combobox" style="height:27px; width:200px;" data-options="editable:false,panelHeight:'auto'">
			<option value="@ConstValues.strSpace">@Resources.All</option>
			<option value="@ConstValues.PaidStatus.已缴费">@Resources.HasPaid</option>
			<option value="@ConstValues.PaidStatus.未缴费">@Resources.HasNotPaid</option>
		</select>&nbsp;&nbsp;
		<a class="easyui-linkbutton" iconcls="icon-search" onclick="searchData()">@Resources.Search</a>
	</div>
	<div class="docs-pictures clearfix" style="display:none"><img id="showTran" style="width:25px;height:25px;" data-original="" src=""></div>
</div>
<div id="dataGrid"></div>

@section bodyParts {
<div id="detailWindow" class="easyui-window"
	title="@Resources.ConferenceTransferEvidence" data-options="closed:true,minimizable:false,maximizable:false,iconCls:'icon-save'"
	style="width:1200px; display:none;">
	<div class="main">
		<div class="box clearfix">
			<h3 id="detailWindowTitle" class="tit01"></h3>
			<form id="frmDetail" method="post" enctype="multipart/form-data">
				@Html.AntiForgeryToken()
				<div id="imgGrid"></div>
				<input type="hidden" id="ids" name="ids" />
				<input type="hidden" id="hidConferenceId" name="conferenceId" />
				<div class="btnDiv">
					@Resources.PayDate : 
					<input id="payTime" name="payTime" class="easyui-datebox" style="height:27px; width:300px;" data-options="editable:false,required:true"/>&nbsp;&nbsp;
					<input type="button" class="gbtn" onclick="exportData();" value="@Resources.ConfirmHasPaid" />&nbsp;&nbsp;
					<input type="button" class="rbtn" onclick="$('#detailWindow').window('close');" value="@Resources.Cancel" />
				</div>
			</form>
		</div>
	</div>
</div>
}

@section Scripts {
<link rel="stylesheet" type="text/css" href="~/Content/dist/viewer.css" />
<script type="text/javascript" charset="utf-8" src="~/Scripts/distJS/bootstrap.min.js"></script>
<script type="text/javascript" charset="utf-8" src="~/Scripts/distJS/viewer.js"></script>
<script type="text/javascript" charset="utf-8" src="~/Scripts/distJS/main.js"></script>
<script>
	common.setCurrentMenu("ConferenceTransferEvidence");
	common.setCurrentParentMenu("#menu_a1");

	$(function () {
		$("#hidConferenceId").val("@Model.ConferenceId");
		$("#queryFullName").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData()
			}
		});
		$("#dataGrid").datagrid({
			url: "@Url.Action(nameof(ConferenceTransferEvidenceController.GetData),
					nameof(ConferenceTransferEvidenceController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
			method: "get",
			singleSelect: true,
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 158,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100, 
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{ field: "id", hidden: true },
				@if ((User as ICISPrincipal).IsSSA || (User as ICISPrincipal).CSAList.Contains(Model.ConferenceId) ||
					Utility.HasConferenceRole((User as ICISPrincipal), Model.ConferenceId, ConstValues.FunctionId.ConferenceTransferEvidence, RoleType.修改))
				{
					<text>
					{
					        field: "operate", title: "@Resources.Operate", align: "center", width: 250,
					        formatter: function(value, rec) {
					        	var strInfo = "";
					        	@if ((User as ICISPrincipal).IsSSA || (User as ICISPrincipal).CSAList.Contains(Model.ConferenceId) || Utility.HasConferenceRole((User as ICISPrincipal), Model.ConferenceId, ConstValues.FunctionId.ConferenceTransferEvidence, RoleType.修改))
						        {
								<text>
					        		strInfo += "<a href='#' style='color:#66CDAA;font-weight:bold;text-decoration:underline;' onclick='editData(\""
									+ rec.id + "\",\""+ rec.transferEvidenceId + "\")'>@Resources.ModifyPayStatus</a>";
					        		</text>
						        }
					        	return strInfo;
					        }
					},
					</text>
				}
				{ field: "fullName", title: "@Resources.FullName", align: "center", width: 200 },
				{ field: "currency", title: "@Resources.Currency", align: "center", width: 100 },
				{ field: "totalFee", title: "@Resources.Price1", align: "center", width: 150 },
				{ field: "discount", title: "@Resources.Price2", align: "center", width: 150 },
				{
					field: "uploadUrl", title: "@Resources.TransferEvidence", align: "center", width: 150 ,
					formatter: function(value, rec) {
                    				var strInfo = "";
                    				strInfo += "<a href='#' style='color:#66CDAA;font-weight:bold;text-decoration:underline;' onclick='showImg(\""
                    						+ value + "\")'>@Resources.TransferEvidence</a>";
                    				return strInfo;
                    			}
				},

				{ field: "hasPaid", title: "@Resources.HasPaid", align: "center", width: 150 },
				{
					field: "status", title: "@Resources.Status", align: "center", sortable: true, width: 150,
	                		formatter: function(value, rec) {
	                			if(value=="@ConstValues.Status.正常"){
	                				return "@Resources.Normal"
	                			}else{
	                				return "@Resources.Pause"
	                			}
	                		}
				},
				{ field: "sort", title: "@Resources.Sort", align: "center", sortable: true, width: 100 },
				{ field: "remark", title: "@Resources.Remark", align: "center", sortable: true, width: 200 },
				{ field: "creator", title: "@Resources.Creator", align: "center", sortable: true, width: 100 },
				{ field: "createIP", title: "@Resources.CreateIP", align: "center", sortable: true, width: 150 },
				{ field: "createDate", title: "@Resources.CreateDate", align: "center", sortable: true, width: 150 },
			]],
			onBeforeLoad: function(param) {
				param.conferenceId = $("#hidConferenceId").val();
				param.random = Math.random();
			}
		});

		$(window).resize(function () {
			$("#dataGrid").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 158
			});
		});

		$("#detailWindow").window({
			onOpen: function () {
				$(this).scrollTop(0);
			},
			top: ($(window).height() - 600) * 0.5
		});
	});

	function searchData() {
		$("#dataGrid").datagrid("load", {
			queryFullName: $("#queryFullName").textbox("getValue"),
			queryHasPaid: $("#queryHasPaid").combobox("getValue"),
		});
	}

	function editData(id, transferEvidenceId) {
		$("#imgGrid").datagrid({
			url: "@Url.Action(nameof(ConferenceTransferEvidenceController.GetEditData),
					nameof(ConferenceTransferEvidenceController).GetControllerName())" + "?transferEvidenceId="+transferEvidenceId,
			method: "get",
			fitColumns: true,
			height: 450,
			nowrap: false,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			columns: [[
				{ field: "chk", align: "center", checkbox: true },
				{ field: "fullName", title: "@Resources.FullName", align: "center", width: 200 },
				{ field: "currency", title: "@Resources.Currency", align: "center", width: 100 },
				{ field: "totalFee", title: "@Resources.Price1", align: "center", width: 150 },
				{ field: "discount", title: "@Resources.Price2", align: "center", width: 150 },
				{ field: "hasPaid", title: "@Resources.PayStatus", align: "center", width: 150 },
			]],
			onBeforeLoad: function(param) {
				param.conferenceId = $("#hidConferenceId").val();
				param.random = Math.random();
			}
		});
		$("#detailWindowTitle").text("@Resources.ModifyPayStatus");
		$("#detailWindow").window("open");
	}

	function exportData() {
		var isValid = $("#frmDetail").form("validate");
		if (isValid) {				
			var rows = $("#imgGrid").datagrid("getChecked");
			if (rows.length > 0) {
				var loading = layer.load(0,  {
					shade: [0.4,"#fff"]
				});
				var ids = "";
				for (var i = 0; i < rows.length; i++) {
					ids += i == 0 ? "" : "&";
					ids += rows[i].id;
				}
				$("#ids").val(ids);
				$.post("@Url.Action(nameof(ConferenceTransferEvidenceController.Modify),
						nameof(ConferenceTransferEvidenceController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
					$("#frmDetail").serialize(),
					function(data, textStatus, jqXHR) {
						layer.close(loading);
						if (data.result == "@ConstValues.AjaxFailResult") {
							common.showError(data.message);
						} else {
							common.showSuccess(data.message, true);
							$("#detailWindow").window("close");
							$("#dataGrid").datagrid("reload");
						}
					}
				);
			} else {
				$.messager.alert("@Resources.ConfirmHasPaid", "@Resources.MsgModifyMust", "warning");
			}
		}
	}

	function showImg(url) {
		$("#showTran").attr("src",url);
		$("#showTran").click()
	}
</script>
}